#include "pmu_driver.h"
#include "timer_1_motor.h"
#include "stdio.h"

void pmu_driver_config(void)
{
}

void pmu_driver_sleepmode(uint8_t sleepmode)
{

    if (sleepmode == 1 || sleepmode == '1')
    {
        printf("进入睡眠模式...\r\n");
        rcu_periph_clock_enable(RCU_PMU);
        pmu_to_sleepmode(WFI_CMD);
    }
    else if (sleepmode == 2 || sleepmode == '2')
    {
        printf("进入睡眠模式...\r\n");
        // 电池管理单元时钟
        rcu_periph_clock_enable(RCU_PMU);
        // 进入深度睡眠模式
        pmu_to_deepsleepmode(PMU_LDO_LOWPOWER, PMU_LOWDRIVER_ENABLE, WFI_CMD);
        // 把主频设置回来
        SystemInit();
    }
    else if (sleepmode == 3 || sleepmode == '3')
    {
        printf("进入待机模式...\r\n");
        // 电池管理单元时钟
        rcu_periph_clock_enable(RCU_PMU);
        // 清理待机模式标记
        pmu_flag_clear(PMU_FLAG_RESET_STANDBY);
        // 启用唤醒引脚
        pmu_wakeup_pin_enable();
        // 进入待机模式
        pmu_to_standbymode();
    }
}

void pmu_driver_test(void)
{
    //timer_1_motor_config();
    //timer_1_motor_set(0.5); // 深度睡眠会停

    //
    /// pmu_driver_config();

    
}
